package com.google.gson.internal.bind;

import com.google.gson.a.a;
import com.google.gson.b.c;
import com.google.gson.b.d;
import com.google.gson.internal.bind.TypeAdapter.Factory;
import com.google.gson.q;
import java.io.IOException;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public final class w extends TypeAdapter {
    public static final Factory a = new Factory() {
        public TypeAdapter create(l lVar, a aVar) {
            return aVar.a() == Time.class ? new w() : null;
        }
    };
    private final DateFormat b = new SimpleDateFormat("hh:mm:ss a");

    public synchronized Time a(com.google.gson.b.a aVar) throws IOException {
        Time time;
        if (aVar.f() == c.NULL) {
            aVar.j();
            time = null;
        } else {
            try {
                time = new Time(this.b.parse(aVar.h()).getTime());
            } catch (Throwable e) {
                throw new q(e);
            }
        }
        return time;
    }

    public synchronized void a(d dVar, Time time) throws IOException {
        dVar.b(time == null ? null : this.b.format(time));
    }

    public /* synthetic */ Object b(com.google.gson.b.a aVar) throws IOException {
        return a(aVar);
    }
}
